//
//  LSZDynamicParentClassVC.m
//  JKFuYinProject
//
//  Created by 九酷 on 2018/8/18.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LSZDynamicParentClassVC.h"
#import "UIViewController+LCHidden.h"

@interface LSZDynamicParentClassVC ()<LSZDisplayViewControllerDelegate>

@property (strong, nonatomic) UIView *viewFenGe;

@end

@implementation LSZDynamicParentClassVC
- (void)loadView {
    [super loadView];
    self.underLineWidth = 18;

}
-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.delegate = self;
    [self.navigationController setNavigationBarHidden:true animated:animated];//返回导航隐藏bug
}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
}
- (void)viewDidLoad {
    self.delegate = self;
    self.strHidderNav = @"1";
    [self setupAllViewController];
    [self setupAllVCData];
    self.titleHeight = NAVIGATION_BAR_HEIGHT;
    /**增加侧滑返回,无其他作用*/
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, ScreenHeight)];
    [self.view addSubview:view];
    [self.view bringSubviewToFront:view];

    UIButton * butAdd =[[UIButton alloc]init];
    butAdd.frame = CGRectMake(3, ScreenHeight-TAB_BAR_HEIGHT-30-50, 50, 50);
    [butAdd setImage:[UIImage imageNamed:@"发布"] forState:UIControlStateNormal];
    [butAdd addTarget:self action:@selector(clickButAdd) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:butAdd];
    //ANewMessage
}
- (void)setupAllViewController {
    // 推荐方式（设置下标）
    [self setUpUnderLineEffect:^(BOOL *isUnderLineDelayScroll, CGFloat *underLineH, UIColor *__autoreleasing *underLineColor, BOOL *isUnderLineEqualTitleWidth) {
        // 标题填充模式
        *underLineColor = [UIColor whiteColor];
        *underLineH = 2;
    }];
    // 标题渐变
    // *推荐方式(设置标题渐变)
    [self setUpTitleGradient:^(LCTitleColorGradientStyle *titleColorGradientStyle, UIColor *__autoreleasing *norColor, UIColor *__autoreleasing *selColor) {
        *norColor = RGBColor(140, 140, 140);
        // 设置标题选中颜色
        *selColor = RGBColor(238, 82, 74);
    }];
    // 设置标题字体
    // 推荐方式
    [self setUpTitleEffect:^(UIColor *__autoreleasing *titleScrollViewColor, UIColor *__autoreleasing *norColor, UIColor *__autoreleasing *selColor, UIFont *__autoreleasing *titleFont, CGFloat *titleHeight, CGFloat *titleWidth) {
        // 设置标题字体
        CGFloat size = [LSZSpecialPackaging initWithReturnsthesizeOf:15 :0.5];
        *titleFont = FONT_(size);
    }];
}
- (void)setupAllVCData {
    // 移除之前所有子控制器
    [self.childViewControllers makeObjectsPerformSelector:@selector(removeFromParentViewController)];
    NSArray *titleDatas = [[NSArray alloc]init];
    titleDatas = @[@"同城",@"动态",@"关注"];
    for (NSInteger i = 0; i < titleDatas.count; i++) {
        if ([titleDatas[i] isEqualToString:@"动态"]) {
            LSZDynamicInformationVC * vc = [[LSZDynamicInformationVC alloc]init];
            vc.title = titleDatas[i];
            [self addChildViewController:vc];
        }
        else{
            LSZNearViewController * vc = [[LSZNearViewController alloc]init];
            vc.title = titleDatas[i];
            if (i == 0) {
                vc.is_city = @"1";
                vc.is_follow = @"";
            }else{
                vc.is_city = @"";
                vc.is_follow = @"1";
            }
            [self addChildViewController:vc];
        }
    }
    // 注意：必须先确定子控制器
    [self refreshDisplay];
    self.selectIndex = 1;
}
-(void)tabBarContentViewDidSelectItemAtIndex:(NSInteger)index{
    NSLog(@"index = %zd", index);
}
-(void)clickButAdd
{
    if([[_UserM usercode] isEqualToString:@""]){
        pushAccLoginVC;
    }else{
        LSZReleaseDynamicVC * VC = [[LSZReleaseDynamicVC alloc]init];
        [self.navigationController pushViewController:VC animated:YES];
    }
}
@end
